package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.PropertyInspectSettingDTO;
import com.itlong.cloud.POJO.VO.property.PropertyInspectSettingVO;
import com.itlong.cloud.inspect.IPropertyInspectSettingServiceClient;
import com.itlong.cloud.property.service.IPropertyInspectSettingService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <desc>
 *      巡检设置暴露接口
 * </desc>
 *
 * @createDate 2019/12/24
 */
@RestController
public class PropertyInspectSettingResource implements IPropertyInspectSettingServiceClient {

    @Autowired
    private IPropertyInspectSettingService iPropertyInspectSettingService;

    /**
     * <desc>
     *      添加巡检设置相关处理。
     * <desc/>
     *
     * @param  dto 巡检相关信息
     * @return
     * @author Juguang.S
     * @createDate 2019-12-24
     */
    @Override
    @PostMapping(path = "/setting/saveInspectPoint")
    public Integer saveInspectPoint(@RequestBody PropertyInspectSettingDTO dto) throws Exception{
        return iPropertyInspectSettingService.saveInspectPoint(dto);
    }

    /**
     * <desc>
     *      获取巡检点编号 即蓝牙门禁deviceUnique。
     * <desc/>
     *
     * @param  dto 巡检点信息
     * @return
     * @author Juguang.S
     * @createDate 2019-12-24
     */
    @Override
    @PostMapping(path = "/setting/getInspectPointNumber")
    public List<String> getInspectPointNumber(@RequestBody PropertyInspectSettingDTO dto){
        return iPropertyInspectSettingService.getInspectPointNumber(dto);
    }

    /**
     * <desc>
     *      获取巡检设置相关分页列表。
     * <desc/>
     *
     * @param  dto 查询条件
     * @return 巡检分页集合
     * @author Juguang.S
     * @createDate 2019-12-24
     */
    @Override
    @PostMapping(path = "/setting/getInspectInfoByPage")
    public Page<PropertyInspectSettingVO> getInspectInfoByPage(@RequestBody PropertyInspectSettingDTO dto) throws Exception{
        return iPropertyInspectSettingService.getInspectInfoByPage(dto);
    }

    /**
     * <desc>
     *      修改巡检设置相关状态。
     * <desc/>
     *
     * @param  dto 修改状态相关参数
     * @return
     * @author Juguang.S
     * @createDate 2019-12-24
     */
    @Override
    @PostMapping(path = "/setting/updateInspectSettingStatus")
    public Integer updateInspectSettingStatus(@RequestBody PropertyInspectSettingDTO dto){
        return iPropertyInspectSettingService.updateInspectSettingStatus(dto);
    }

    /**
     * <desc>
     *      校验巡检区域、巡检点、巡检路线、巡检计划的名称是否存在。
     * <desc/>
     *
     * @param  dto 巡检相关信息
     * @return
     * @author Juguang.S
     * @createDate 2019-12-25
     */
    @Override
    @PostMapping(path = "/setting/isExistByInspectName")
    public Integer isExistByInspectName(@RequestBody PropertyInspectSettingDTO dto){
        return iPropertyInspectSettingService.isExistByInspectName(dto);
    }

    /**
     * <desc>
     *      删除巡检相关需校验是否与上级有所关联，有关联不允许删除。
     * <desc/>
     *
     * @param  dto 巡检信息
     * @return
     * @author Juguang.S
     * @createDate 2019-12-26
     */
    @Override
    @PostMapping(path = "/setting/isRelationByInspect")
    public Integer isRelationByInspect(@RequestBody PropertyInspectSettingDTO dto){
        return iPropertyInspectSettingService.isRelationByInspect(dto);
    }

    /**
     * <desc>
     *      获取巡检路线详情。
     * <desc/>
     *
     * @param  dto 巡检路线ID
     * @return 巡检路线详情
     * @author Juguang.S
     * @createDate 2019-12-26
     */
    @Override
    @PostMapping(path = "/setting/getInspectLineInfo")
    public PropertyInspectSettingVO getInspectLineInfo(@RequestBody PropertyInspectSettingDTO dto){
        return iPropertyInspectSettingService.getInspectLineInfo(dto);
    }

    /**
     * <desc>
     *      获取巡检点列表。
     * <desc/>
     *
     * @param  dto 项目ID
     * @return 巡检点列表
     * @author Juguang.S
     * @createDate 2019-12-27
     */
    @Override
    @PostMapping(path = "/setting/getInspectPointList")
    public List<PropertyInspectSettingVO> getInspectPointList(@RequestBody PropertyInspectSettingDTO dto){
        return iPropertyInspectSettingService.getInspectPointList(dto);
    }

    /**
     * <desc>
     *      根据巡检相应ID获取名称。
     * <desc/>
     *
     * @param  dto 巡检相关信息
     * @return
     * @author Juguang.S
     * @createDate 2020-01-08
     */
    @Override
    @PostMapping(path = "/setting/getInspectNameById")
    public PropertyInspectSettingVO getInspectNameById(@RequestBody PropertyInspectSettingDTO dto){
        return iPropertyInspectSettingService.getInspectNameById(dto);
    }


}
